package exam.demo19;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for(int a = 0; a < t; a++) {
            int n = in.nextInt();
            char[] arr = new char[n];
            for(int i = 0; i < n; i++) {
                arr[i] = in.next().toCharArray()[0];
            }
            if(n % 2 == 1) {
                if (n == 1) {
                    System.out.println("Yes");
                    continue;
                }
                int mid = n / 2;
                int left = mid - 1;
                int right = mid + 1;
                while(left >= 0 && right < n) {
                    if(arr[left] != arr[right]) {
                        System.out.println("No");
                        break;
                    }
                    left--;
                    right++;
                }
                if(left == -1) {
                    System.out.println("Yes");
                }
            }else{
                int mid = n / 2;
                int left = mid - 1;
                int right = mid;
                while(left >= 0 && right < n) {
                    if(arr[left] != arr[right]) {
                        System.out.println("No");
                        break;
                    }
                    left--;
                    right++;
                }
                if(left == -1) {
                    System.out.println("Yes");
                }
            }
        }
    }
}
